/*
 * @Description: 
 * @Autor: 商晓彬
 * @Date: 2021-08-09 08:57:57
 * @LastEditors: 商晓彬
 * @LastEditTime: 2022-01-04 14:29:36
 */
import { AfterViewChecked, Component, ElementRef, EventEmitter, Injector, Input, Output, ViewChild } from '@angular/core';
import { AppConsts } from '@shared/AppConsts';
import { AppComponentBase } from '@shared/common/app-component-base';
import { OperationHistoryServiceProxy } from '@shared/service-proxies/service-proxies';
import { ModalDirective } from 'ngx-bootstrap';
import { IOrganizationUnitsTreeComponentData, OrganizationUnitsTreeComponent } from '../../shared/organization-unit-tree.component';
import * as _ from 'lodash';
import { finalize } from 'rxjs/operators';
import { MessageService } from '@abp/message/message.service';

@Component({
    selector: 'app-show-resume',
    templateUrl: './show-resume.component.html',
    styleUrls: ['./show-resume.component.less']
})
export class ShowResumeComponent extends AppComponentBase {
    //引入子组件
    @ViewChild('createOrEditModal') modal: ModalDirective;
    @Input() parentInfo: any;
    active = false;
    //表格
    tableData = []
    constructor(
        injector: Injector,
        private _messageService: MessageService,
        private _operationHistoryService: OperationHistoryServiceProxy
    ) {
        super(injector);
    }
    getData(row) {
        var reg = /^\【/gi;
        var reg2 = /\】$/gi;
        let str = row;
        str = str.replace(reg, '');
        let rs = str.split('】');
        return '导出规程' + rs[0];
    }
    export(row) {
        this.message.confirm(
            '是否下载？',
            (isConfirmed) => {
                if (isConfirmed) {
                    var reg = /^\【/gi;
                    var reg2 = /\】$/gi;
                    let str = row;
                    str = str.replace(reg, '');
                    let rs = str.split('】');
                    window.location.href = rs[1];
                }
            }
        );
    }
    //获取表格数据
    getTableList() {
        if (this.parentInfo && this.parentInfo.id) {
            this._operationHistoryService.getOperationLogList(this.parentInfo.id)
                .pipe(finalize(() => { }))
                .subscribe(result => {
                    this.tableData = result
                })
        }
    }
    //查看新增任务
    show(): void {
        this.active = true;
        this.modal.show();
    }
    //关闭事件
    close(): void {
        this.active = false;
        this.modal.hide();
    }
    onShown(): void {

    }

}
